home *** CD-ROM | disk | FTP | other *** search
- // *************************************************************************
- // Plasma cloud generator
- // by Maple Leaf, Dec 1996
- // -----------------------------------------------------------------------
- // No rights reserved
- // *************************************************************************
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
-
- void main()
- {
- float x,y,count,i;
- int lead,offset;
- FILE *fp;
- unsigned char value;
-
- printf("\nPlasma generator, by Maple Leaf, 1996\n\nProcessing ...!\n");
-
- if (!(fp=fopen("PLASMA.DAT","wb")))
- {
- printf("\7Cant open output file PLASMA.DAT\n");
- exit(255);
- }
-
- /* First generate the plasma map. This is effectively just an
- arbitrary function of x and y which gives a smooth but
- non-uniform surface */
-
- printf("\nGenerating main map ");
- for (y=0;y<300;y++) {
- for (x=0;x<512;x++)
- {
- value=64+ 7*( sin(x/20) + cos(y/180) +
- cos(x/40) + sin((x-y)/70) +
- sin((x+2*y)/70) +
- sin(hypot(256-x,150-y/8)/10) -
- cos((x*4-y*2)/70) +
- sin(2*cos((y*4-x*2)/100))
- );
- fputc(value,fp);
- }
- if ((int)y % 30 == 0) printf(".");
- }
-
- printf("\nGenerating movement path ...");
- /* Then arbitrary movement for two pointers */
-
- for (count=0;count<10000;count++)
- {
- lead= 96+92*cos(count/32)
- +512*(int)(48+47*sin(count/16));
- offset= 96+92*sin(count/21)
- +512*(int)(48+47*cos(count/24))
- -lead;
- fwrite(&lead,2,1,fp);
- fwrite(&offset,2,1,fp);
- }
-
- printf("\nGenerating palette ...\n");
- /* And a smooth transition colour lookup table */
-
- for (i=-256; i<256*39; i++)
- if (i<0)
- {
- fputc(0,fp);
- fputc(0,fp);
- fputc(0,fp);
- }
- else
- {
- fputc((sin(i/30)*cos(i/50)*31+31),fp);
- fputc((sin(i/400)*cos(i/100)*31+31),fp);
- fputc((cos(i/200)*sin(i/300)*31+31),fp);
- }
- fclose(fp);
- }
-